﻿@{
    ViewBag.Title = "TimeClassInfo";
}

@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <link href="~/Scripts/miniui/themes/default/medium-mode.css" rel="stylesheet" type="text/css" />      
}

<form id="form1" method="post">
            @Html.Partial("~/Views/Modular/Toolbars.cshtml")
        <div name="Base" title="次卡分类" style="height:100%;overflow:hidden;margin-top:15px;margin-left:0px">
            <table>
                <tr>
                    <td width="80px" height ="50px" align="right">
                        编码：</td>
                    <td width="200px" height ="50px">
                        <input name="FNumber" id="FNumber" class="mini-textbox" style="width:200px;"  value="" TabIndex="1"/>
                    </td>
                    <td width="80px" height ="50px" align="right">
                        类型：</td>
                    <td width="200px" height ="50px">
                        <input name="FClassName" id="FClassName" class="mini-textbox" style="width:200px;"  value="" TabIndex="1" readonly="true"/>
                    </td>
               </tr>
                <tr>
                    <td width="80px" height ="50px" align="right">
                        名称：</td>
                    <td width="200px" height ="50px">
                        <input id="FName" name="FName" class="mini-textbox " style="width:200px;" TabIndex="2"/>
                    </td>
                    <td width="80px" height ="50px" align="right">
                        备注：</td>
                    <td width="200px" height ="50px">
                        <input id="FRemark" name="FRemark" class="mini-textbox " style="width:200px;"  TabIndex="3"/>
                    </td>
                </tr>
            </table>
        </div>
    <input name="FItemID" class="mini-hidden" />
    <input name="FClassID" class="mini-hidden" />
</form>


<script>
    mini.parse();

   function FormShown() {
    }

    //加载资料
    function SetInfoData(data) {
        if (data.action == "new") {
            //跨页面传递的数据对象，克隆后才可以安全使用
            mini.getbyName("FItemID").setValue('0');
            mini.getbyName("FClassID").setValue(data.FClassID);
            mini.getbyName("FClassName").setValue(data.FClassName);
            NewInfo();
        }
        else {
            $.post("GetTimeClass", { json: "[{'FItemID':'" + data.FItemID + "','mSystemAppID':'" + parent.window.getSystemAppID() + "'}]" }, function (data) {
                var form = new mini.Form("form1");
                var mdata = mini.decode(data);
                if (mdata.data.length > 0) {
                    mini.getbyName("FItemID").setValue(mdata.data[0].FItemID);
                    form.setData(mdata.data[0]);
                    mini.getbyName("FNumber").setEnabled(false);
                }
            });
        }

    }

    //新增资料
    function NewInfo() {
        mini.getbyName("FItemID").setValue("0");
        mini.getbyName("FName").setValue("");
        var jsonstr = '{"mSystemAppID":"' + parent.window.getSystemAppID() + '"}';
        $.post('NewTimeClass', { json: jsonstr }, function (data) {
            mini.getbyName("FNumber").setValue(data);
        });
    }

    //保存资料
    function SaveInfo() {
        if (mini.getbyName("FName").getValue() == "") {
            mini.alert("名称不能为空");
            return;
        }
        mini.getbyName("SaveInfo").setEnabled(false);
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) {
            mini.getbyName("SaveInfo").setEnabled(true);
            return;
        }
        var data = form.getData(true, false);
        var json = mini.encode(data);
        $.post("SaveTimeClass", { json: json, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                mini.showTips({ content: '保存成功', state: "success", x: "center", y: "top", timeout: 3000 });
                NewInfo();
            }
            else {
                mini.alert("异常:" + ret.error);
            }
            mini.getbyName("SaveInfo").setEnabled(true);
        });
    }

</script>